/*
 * (C) Copyright 2013 Aepona Limited. All Rights Reserved.
 *
 * These materials are unpublished, proprietary, confidential source code of Aepona Limited and constitute a
 * TRADE SECRET of Aepona Limited.
 *
 * Aepona Limited retains all title to and intellectual property rights in these materials.
 */

package com.intel.sam.modulePartnerIntegration;

import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.URL;

/**
 * Created by IntelliJ IDEA.
 * User: ak40260
 * Date: 5/23/13
 */
public class WebApplicationTestingHelper
    extends WebApplicationTestingConstraints
{

    public static WebDriver initialiseWebDriver( Platform platform, String browser )
        throws java.lang.Exception
    {
        // Set Capabilities
        DesiredCapabilities capabilities = setCapability( platform, browser );

        // Set Hub URL
        URL hubUrl = setHubUrl();

        // Initialise WebDriver
        return new RemoteWebDriver( hubUrl, capabilities );
    }

    public static DesiredCapabilities setCapability( Platform platform, String browser )
        throws java.lang.Exception
    {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName( browser );
        capabilities.setPlatform( platform );
        capabilities.setCapability( "ensureCleanSession", "true" );
        return capabilities;
    }

    public static URL setHubUrl()
        throws java.lang.Exception
    {
        return new URL( HUB_URL );
    }

}
